package CountingSort;


import java.awt.Font;
import javax.media.j3d.Appearance;
import javax.media.j3d.ColoringAttributes;
import javax.media.j3d.Font3D;
import javax.media.j3d.FontExtrusion;
import javax.media.j3d.Shape3D;
import javax.media.j3d.Text3D;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.vecmath.Color3f;
import javax.vecmath.Point3f;
import javax.vecmath.Vector3f;

/**
 *
 * @author rafael
 */
public class Number {


    public TransformGroup tgNumber;
    public int numero;

    public Number(int number, TransformGroup tg){

        addNumber(number);
        addTGNumber(tg);
        addText();

        tgNumber.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
        tgNumber.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

    }

    public void addNumber(int n){
    numero = n;
    }

    public void addTGNumber(TransformGroup trans){
    tgNumber = trans;
    }

    public int getNumber(){
    return numero;
    }

    public TransformGroup getTGNumber(){
    return tgNumber;
    }
    
    public void addText() {

        Font3D fonte = new Font3D(new Font("Century Gothic", Font.BOLD, 1), new FontExtrusion());
        Text3D texto = new Text3D(fonte, new String(Integer.toString(numero)), new Point3f(0.0f, 0.0f, 0.0f));

        Appearance aparencia = new Appearance();

        ColoringAttributes corAP = new ColoringAttributes(new Color3f(0.3f, 0.2f, 0.7f), 1);
        aparencia.setColoringAttributes(corAP);

        Shape3D aparenciaTexto = new Shape3D(texto);

        aparenciaTexto.setAppearance(aparencia);

        Transform3D tfTexto = new Transform3D();
        tfTexto.setScale(Main.raio * 2 - 0.1f);

        tfTexto.setTranslation(new Vector3f(-Main.raio/2, -Main.raio/2, Main.raio));
        TransformGroup tgTexto = new TransformGroup(tfTexto);

        tgTexto.addChild(aparenciaTexto);
        tgNumber.addChild(tgTexto);

    }

}
